package com.example.Opd_ISF_Android_Application.view.activities;


import com.example.Opd_ISF_Android_Application.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.example.Opd_ISF_Android_Application.controller.LoginManager;

/**
 * Created with IntelliJ IDEA.
 * User: Dell
 * Date: 26/03/13
 * Time: 9:55
 * To change this template use File | Settings | File Templates.
 */
public class SplashActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);    //To change body of overridden methods use File | Settings | File Templates.
        this.setContentView(R.layout.splash);
        //Check if there is a network
        if (LoginManager.isOnline(this)) {
            Thread t = new Thread() {
                public void run() {
                    try {
                        // Let the splash show for 1.5 seconds
                        sleep(1500);
                    } catch (Exception e) {
                        //do nothing
                    } finally {
                        Intent mainActivity = new Intent(getResources().getString(R.string.mainIntent));
                        startActivity(mainActivity);
                        finish();
                    }
                }
            };
            t.start();
        } else {
            // Pop activity from stack
                finish();
        }
    }


}
